﻿<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"
  assembly="JSC.Portal.Web.App" namespace="JSC.Portal.Web.App.Modules.Articles.Entities">

	<class name="Article" table="jscm_article" lazy="false">

		<!-- start Base on every entity -->
		<id name="Id" column="articleid" unsaved-value="-1">
			<generator class="native">
				<param name="sequence">jscm_article_articleid_seq</param>
			</generator>
		</id>
		<!-- end Base on every entity -->

		<property name="Title" column="name"/>
		<property name="Description" column="description"/>
		<property name="Content" column="content" type="StringClob" />
		<property name="ValidFrom" column="validfrom"/>
		<property name="ValidTill" column="validtill"/>
		<property name="Syndicate" column="syndicate"/>

    <many-to-one name="ArticleCategory" class="ArticleCategory" column="articlecategoryid" not-null="false" not-found="ignore" outer-join="true" cascade="none"/>
    
    <bag name="Comments" table="jscm_articlecomment" inverse="true" lazy="true" cascade="all-delete-orphan">
			<key column="articleid" />
			<one-to-many class="Comment" not-found="ignore" />
		</bag>

    <property name="CreatedOn" column="createdtimestamp" type="DateTime"/>
    <property name="ModifiedOn" column="modifiedtimestamp" type="DateTime"/>
    <many-to-one name="CreatedByUser" class="JSC.Portal.Entities.PortalUser, JSC.Portal.Core" column="createdby" not-null="false" not-found="ignore"/>
    <many-to-one name="ModifiedByUser" class="JSC.Portal.Entities.PortalUser, JSC.Portal.Core" column="modifiedby" not-null="false" not-found="ignore"/>
    <many-to-one name="Section" class="JSC.Portal.Entities.Section, JSC.Portal.Core" column="sectionid" not-null="false" not-found="ignore"/>
  </class>
</hibernate-mapping>